<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>登录页面</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/login.css">
    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/iview.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="libs/html5shiv.min.js"></script>
    <script src="libs/respond.min.js"></script>
    <![endif]-->
    <script>

    </script>
</head>
<body class="signin hold-transition login-page">
<div class="loginscreen animated fadeInDown signinpanel" id="loginBox" v-cloak>

            <Card class="m-t text-center" style="background: rgba(109, 109, 109, 0.23);width:400px;margin:0 auto;border: 0px solid rgba(172,213,209,0.71);">
                <p style="padding: 0 20px 20px 20px; font-size:20px;color:rgba(255,245,255,0.97)">登录到管理平台</p>
                <div class="form-group has-feedback">
                    <i-input v-model="loginParams.userName" @on-enter="login" placeholder="账号" style="width: 200px;" autofocus/>
                </div>
                <div class="form-group has-feedback">
                    <i-input type="password" v-model="loginParams.password" @on-enter="login" style="width: 200px;"
                             placeholder="密码"/>
                </div>
                <div class="form-group has-feedback">
                    <div style="display: inline-block;width: 100px;">
                        <i-input v-model="loginParams.captcha" @on-enter="login"
                                 placeholder="验证码"/>
                    </div>
                    <div style="display: inline-block;width: 100px;">
                        <img style="height: 32px;width: 96px;border-radius: 4px;" alt="如果看不清楚，请单击图片刷新！" title="点击刷新"
                             class="pointer" :src="loginParams.src" @click="refreshCode">
                    </div>
                </div>
                <div>
                    <i-button type="primary" @click="login" style="width: 200px;">登录</i-button>
                </div>
            </Card>
<!--    <div class="signup-footer">-->
<!--        <div class="pull-left">-->
<!--        </div>-->
<!--    </div>-->
</div>
<!-- /.login-box -->
<script src="libs/jquery.min.js"></script>
<script src="libs/vue.min.js"></script>
<script src="libs/iview.min.js"></script>
<script src="libs/bootstrap.min.js"></script>
<script src="plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="libs/fastclick.min.js"></script>
<script type="text/javascript">
    var vm = new Vue({
        el: '#loginBox',
        data: {
            loginParams:{
                userName: 'admin',
                password: '123456',
                captcha: '',
                src: 'captcha.jpg'
            }
        },
        beforeCreate: function () {
            if (self != top) {
                top.location.href = self.location.href;
            }
        },
        methods: {
            refreshCode: function () {
                this.loginParams.src = "captcha.jpg?t=" + $.now();
            },
            login: function (event) {
                if (vm.loginParams.username == '') {
                    iview.Message.warning("用户名为空");
                    return false;
                }
                if (vm.loginParams.password == '') {
                    iview.Message.warning("密码为空");
                    return false;
                }
                // if (vm.loginParams.captcha == '') {
                //     iview.Message.warning("验证码为空");
                //     return false;
                // }
                $.ajax({
                    type: "POST",
                    url: "sys/login",
                    data: JSON.stringify(vm.loginParams),
                    dataType: "json",
                    contentType: "application/json",
                    success: function (result) {
                        if (result.code == 200) {//登录成功
                            parent.location.href = 'index';
                        } else {
                            vm.refreshCode();
                            iview.Message.error(result.message);
                        }
                    }
                });
            }
        },
    });
</script>
</body>
</html>
